package com.clstu.printwriter;

import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

public class PrintWriter_ {
    public static void main(String[] args) throws IOException {
        PrintWriter printWriter = new PrintWriter(new FileWriter("D:\\hi.txt"));
        PrintWriter printWriter1 = new PrintWriter(System.out);//字符打印流
        printWriter1.write("hello world");//打印到显示器，注意要用close()方法才能真正的打印到显示器，不然不显示
        printWriter.write("hi,玛卡巴卡");
        printWriter.close();
        System.out.println("文件打印成功~~~");
        printWriter1.close();//真正写入（打印）的方法
    }
}
